var prmap;
function whetherPrint(vbMap){
    $.ajax({
        type : 'get',
        url :memberHostUrl + '/his/horate/checkout/queryReceiptNumbercaback',
        data : {
            bce01:$.cookie('employeeId'),
            aak01:5
        },
        dataType : "jsonp",
        async:false,
        success : function(data) {
            if(data.result=="SUCCESS"){
                prmap = data.list[0];
                if(data.list){
                    var confirmindex=layer.confirm("确定要打印小票吗？ ",{
                        btn:['确定','取消'],icon:3
                    },function(){
                        layer.close(confirmindex);
                        assignprint(vbMap);
                        getbillupdates(vbMap);
                    });
                }
            }else{
                layer.msg(data.resultMsg, {icon: 2});
            }
        }
    })

}


//预览票据
function assignprint(vbMap){
    $.ajax({
        url: printUrl+"/printtemprest/findListByRid/320?jsessionids="+$.cookie('jsessionids'),
        type: "GET",
        dataType: "json",
        traditional: true,
        async: false,
        success: function (data) {
            if(data){
                printViews(data[0].id,vbMap);
            }else{
                layer.msg("暂无当前打印数据!",{icon:2});
                return;
            }
        },
        error: function (err) {
            layer.msg("加载打印格式错误!",{icon:2});
            return;
        }
    });
}


function  printViews(id,vbMap){
    var url = printUrl+"/printtoolrest/printToPdfView/"+id+"?vbl01="+vbMap.vbl01;
    var that= this;
    var data={};
    layer.open({
        type: 2,
        title: "充值票据",
        shadeClose: true,
        shade: 0.8,
        area: ['100%', '100%'],
        content: url, //iframe的url,
        success:function(){
            console.log($("#icon"));
        }
    });
}


function getbillupdates(vbMap){
    var jsonData = [];
    jsonData.push({name:'atype',value:'2'});
    jsonData.push({name:'printcount',value:'1'});
    jsonData.push({name:'billtype',value:'0'});
    jsonData.push({name:'vak01',value: vbMap.vbl01});//*
    jsonData.push({name:'fab14',value: '正常打印'});
    jsonData.push({name:'bce03',value: $.cookie('trueName')});
    jsonData.push({name:'loginbce01',value: $.cookie('employeeId')});
    jsonData.push({name:'fac01',value: 0});
    jsonData.push({name:'aak01',value: 5});//*
    jsonData.push({name:'fab03',value: prmap.Bill});//*
    jsonData.push({name:'fab04',value: 1});//*
    jsonData.push({name:'fab05',value: 1});//*
    jsonData.push({name:'faa01',value: prmap.BillId});//*
    jsonData.push({name:'vai04',value: vbMap.vbl02});//*
    //获取病人信息的数据
    var mydata = JSON.stringify(jsonData);
    console.log(mydata);
    $.ajax({
        type : 'post',
        url :memberHostUrl + '/his/horate/registration/horatebillupdatecaback',
        data : {'mydata' :mydata },
        dataType : "jsonp",
        success : function(data) {
            console.log(data);
        }
    });
}
